const cityurl='https://geoapi.qweather.com/v2/city/lookup?key=0cbff7d60a7142e4b66d8fffcc5dae3e&location='
const weatherurl='https://devapi.qweather.com/v7/weather/now?key=0cbff7d60a7142e4b66d8fffcc5dae3e&location='
const futureurl='https://devapi.qweather.com/v7/weather/3d?key=0cbff7d60a7142e4b66d8fffcc5dae3e&location='
Page({
data:{
  city:'',
  temperature:'',
  wind:'',
  cityid:'',
},
input(e){
  console.log(e)
  let city=e.detail.value
  this.setData({
    city:city
  })
  this.search()
},
search(){
  let url=cityurl+this.data.city
  console.log('cityidurl:',url)
  let that = this
  wx.request({
    url,
    success(e){
      console.log('cityid:',e)
      let cityid= e.data.location[0].id
      that.setData({
        cityid
      })
      let wurl = weatherurl+cityid
      console.log('weatherurl:',url)
      wx.request({
        url:wurl,
        success(e){
        console.log('weather:',e)
        let temperature=e.data.now.temp
        let weather=e.data.now.text
        let wind = e.data.now.windDir
        let humidity=e.data.now.humidity+"%"
        let windScale=e.data.now.windScale+"级"
        let pressure=e.data.now.pressure
        
        that.setData({
          temperature,weather,wind,humidity,windScale,pressure
        })
        }
      })
      let furl=futureurl+cityid
      console.log('futureurl:',furl)
      wx.request({
        url:furl,
        success(e){
          console.log('future:',e)
          let daily = e.data.daily
          that.setData({
            daily
          })
        }
      })
    }
  })
}
})